package org.zr;

import org.apache.dubbo.config.*;
import org.zr.api.TestApi;
import org.zr.api.impl.TestApiImpl;

public class ServiceExporter {
    public static void main(String[] args) {
        TestApi api = new TestApiImpl();
        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("service-api");

        RegistryConfig registryConfig = new RegistryConfig();
        registryConfig.setAddress("zookeeper://127.0.0.1:2181");
        ProtocolConfig protocolConfig = new ProtocolConfig();
        protocolConfig.setName("dubbo");


        ServiceConfig<TestApi> serviceConfig = new ServiceConfig<TestApi>();
        serviceConfig.setId("testApi");
        serviceConfig.setRef(api);
        serviceConfig.setInterface(TestApi.class);
        serviceConfig.setProtocol(protocolConfig);
        serviceConfig.setRegistry(registryConfig);
        serviceConfig.setApplication(applicationConfig);
        serviceConfig.export();
        System.out.println("服务已发布。");
        while(true){

        }
    }
}
